home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / pascal / swag / printing.swg / 0015_Check for Printer Ready.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-06-22  |  1.4 KB  |  41 lines

  1. ===========================================================================
  2.  BBS: The Beta Connection
  3. Date: 06-08-93 (20:02)             Number: 819
  4. From: JEFF PALEN                   Refer#: 777
  5.   To: DAN SABIN                     Recvd: YES 
  6. Subj: PRINTER CRASHING               Conf: (232) T_Pascal_R
  7. ---------------------------------------------------------------------------
  8. DS>Does anyone know how you can check from Turbo Pascal that the
  9. DS>printer is turned on so that you won't get a device error that
  10. DS>will crash a program?  I can't find anything about this.
  11.  
  12. Program  Printer_Status;
  13. Uses Dos;
  14. Function PrinterOnLine : Boolean;
  15.   Const
  16.     PrnStatusInt  : Byte = $17;    (*  Dos interrupt *)
  17.     StatusRequest : Byte = $02;    (*  Interrupt Function Call *)
  18.  
  19.     PrinterNum    : Word = 0;  { 0 for LPT1, 1 for LPT2, etc. }
  20.   Var
  21.     Regs : Registers ;         { Type is defined in Dos Unit }
  22.  
  23.     Begin  (* PrinterOnLine*)
  24.       Regs.AH := StatusRequest;
  25.       Regs.DX := PrinterNum;
  26.       Intr(PrnStatusInt, Regs);
  27.       PrinterOnLine := (Regs.AH and $80) = $80;
  28.     End;
  29.  
  30. Begin (* Main Program *)
  31.   If PrinterOnLine Then
  32.     Writeln('Ready To Print')
  33.   Else
  34.     Writeln('Please check the printer!');
  35. End.
  36.  
  37. ---
  38.  ■ RM 1.0  ■ Eval Day 4 ■ Programmer's do it with bytes and nybbles....
  39.  * Channel 1(R) * 617-354-7077 * Cambridge MA * 85 lines
  40.  * PostLink(tm) v1.06  CHANNEL1 (#15) : RelayNet(tm)
  41.